package model;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import lombok.*;
import org.hibernate.annotations.NaturalId;

@Entity
@Table(name = "my_user")
public @Data class User {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", columnDefinition = "bigint", nullable = false)
    private long id;

    @Column(name = "name", columnDefinition = "varchar(200)", nullable = false)
    private String name;

    @Column(name = "first_name", columnDefinition = "varchar(200)", nullable = false)
    private String firstName;

    @ManyToOne(optional = true)
    @JoinColumn(name="id_img")
    private Image image;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
    //@JsonManagedReference
    @JsonBackReference
    private List<Hobby> hobbies;
}
